<?php 
    $storeId = Mage::app()->getStore()->getId();
	$posts = Mage::getModel('blog/post')->getCollection()
			->setStoreId($storeId)	
			->addAttributeToSelect('*')
			->addAttributeToFilter('status',1)
			->addAttributeToSort('created_at','DESC');
    $thumnailWidth = Mage::getStoreConfig('blog/info/recent_thumbnail_width');
	$thumnailHeight = Mage::getStoreConfig('blog/info/recent_thumbnail_height');
    $helper = Mage::helper('cms');
	$helperBlog = Mage::helper('blog'); 
?>
<?php if($posts->count() > 0):?> 
    <?php $i=0; foreach ($posts as $p): ?>    
        <div class="em-blog-item em-effect-13 em-blog-style02">
    		<div class="em-blog-content bkg-top">
    			<?php if($p->getImage()):?>
    			<a title="em-sample-title" class="img-banner-small" href="<?php echo $p->getPostUrl();?>">
    				<img alt="em_blog" class="img-responsive" src="<?php echo $helperBlog->resizeImage($p->getImage(),$thumnailWidth,$thumnailHeight,"emblog/post",'thumbnail');?>"/>
    			</a>
    			<?php endif;?>
                <?php $date = new DateTime($p->getCreatedAt());?>                    
                <div class="em-blog-time">
                    <p class="em-blog-date"><?php echo $date->format('j'); ?></p>
                    <p class="em-blog-month"><?php echo $date->format('M'); ?></p>
                </div>
    			<div class="hov">&nbsp;</div>
    		</div>
    		<div class="em-box bkg-bottom">
				<?php
                    $title = $p->getTitle();
                    if (strlen($title) > 25)
                    {
                        $temp = substr($title, 0, 25);
                        $plit = explode(" ", $temp);
                        $temp = array_slice($plit, 0, count($plit) - 1);
                        $title = implode(" ", $temp);
                    }
                ?>
				<h4 class="em-blog-title"><a href="<?php echo $p->getPostUrl(false);?>"><?php echo strip_tags($title);?>&hellip;</a></h4>
                <?php
                    $content = $p->getPostIntro();
                    if (strlen($content) > 145)
                    {
                        $temp = substr($content, 0, 145);
                        $plit = explode(" ", $temp);
                        $temp = array_slice($plit, 0, count($plit) - 1);
                        $content = implode(" ", $temp);
                    }
                ?>
    			<p class="em-blog-des"><?php echo strip_tags($content)?>&hellip;</p>
				<p><a class="link-more" href="<?php echo $p->getPostUrl();?>"><?php echo $this->__('Read more') ?></a></p>
			</div>
    	</div>
    <?php $i++;?>
    <?php if($i>=4) break;?>           
    <?php endforeach; ?>
<?php else:?>
    <p class="note-msg"><?php echo $this->__('There are no posts matching the selection.')?></p>
<?php endif;?>